﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Clandestine.Entities
{
    public class SimpleDialogueNPC : NPC
    {
        private string conversationName = string.Empty;
        public string ConversationName
        {
            get { return conversationName; }
            set { conversationName = value; }
        }

        public bool TurnToFacePlayer { get; set; }

        public override bool CanUse
        {
            get
            {
                return true;
            }
        }



        public SimpleDialogueNPC()
        {
            TurnToFacePlayer = true;
        }

        internal override void think()
        {
            // nobody here but us chickens.   
        }

        public override void OnUse(int playerXPos, int playerYPos)
        {
            if (TurnToFacePlayer)
                facePoint(playerXPos, playerYPos);

            Conversations.Conversation.Start(ConversationName);
        }

        private void facePoint(int playerXPos, int playerYPos)
        {
            int xdist = Math.Abs(Position.X - playerXPos);
            int ydist = Math.Abs(Position.Y - playerYPos);
            if (xdist > ydist)
            {
                if (playerXPos <= Position.X)
                    Direction = Direction.Left;
                else
                    Direction = Direction.Right;
            }
            else
            {
                if (playerYPos <= Position.Y)
                    Direction = Direction.Up;
                else
                    Direction = Direction.Down;
            }
        }
    }
}
